﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.SharePoint.Common.Logging;

namespace SoftwareCraft.SharePoint.Diagnostics.Demo
{
    /// <summary>
    /// Extension methods for the <see cref="Microsoft.Practices.SharePoint.Common.Logging"/> classes.
    /// </summary>
    public static class DiagnosticsExtensions
    {
        /// <summary>
        /// Determines if a specified diagnostics area exists in the <see cref="DiagnosticsAreaCollection"/>.
        /// </summary>
        /// <param name="name">The name of diagnostics area to locate.</param>
        /// <returns>True if the diagnostics area exists, false otherwise.</returns>
        public static bool Contains(this DiagnosticsAreaCollection areas, string name)
        {
            return areas.Any(area => area.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
        }
        /// <summary>
        /// Determines if a specified diagnostics category exists in the <see cref="DiagnosticsCategoryCollection"/>.
        /// </summary>
        /// <param name="name">The name of diagnostics category to locate.</param>
        /// <returns>True if the diagnostics category exists, false otherwise.</returns>
        public static bool Contains(this DiagnosticsCategoryCollection categories, string name)
        {
            return categories.Any(category => category.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
        }
    }
}
